<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="common/head :: head"></head>
<script type="text/javascript">
  $(function(){
    $('#ec').validate({
      rules:{
        name:"required"
      },
      messages:{
        name:"权限名称必须输入"
      },
      submitHandler: function(form) {
        $(form).find(":submit").attr("disabled", true).text("正在提交...");
        form.submit();
      }
    });
  });
</script>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
  <div class="ibox float-e-margins">
    <div class="ibox-content" style="width: 98%;">
      <form id="ec" th:action="@{/permission/update}" method="post" class="form-horizontal">
        <input type="hidden" name="id" th:value="${permission.id}">
        <input type="hidden" name="parentId" th:value="${permission.parentId}">
        <!--因为加了健壮性判断是根据父菜单的id来判断其子菜单列表的所以这里要加一条隐藏parentId-->

        <div class="form-group">
          <label class="col-sm-2 control-label">权限名称：</label>
          <div class="col-sm-10">
            <input type="text" name="name" id="name" th:value="${permission.name}" class="form-control"/>
          </div>
        </div>
        <div class="hr-line-dashed"></div>
        <div class="form-group" th:if="${permission.type == 1 && permission.parentId != 0}">
          <label class="col-sm-2 control-label">菜单url：</label>
          <div class="col-sm-10">
            <input type="text" name="url" id="url" th:value="${permission.url}" class="form-control" style="width:100%;height: 50px;" ></input>
          </div>
        </div>
        <div class="hr-line-dashed" th:if="${permission.type == 1}"></div>
        <div class="form-group" th:if="${permission.type == 2}">
          <label class="col-sm-2 control-label">权限值：</label>
          <div class="col-sm-10">
            <input type="text" name="code" id="code" th:value="${permission.code}" class="form-control" style="width:100%;height: 50px;" ></input>
          </div>
        </div>
        <div class="hr-line-dashed" th:if="${permission.type == 2}"></div>
        <div class="form-group">
          <label class="col-sm-2 control-label">排序：</label>
          <div class="col-sm-10">
            <input type="text" name="sort" id="sort" th:value="${permission.sort}" class="form-control"/>
          </div>
        </div>
        <div class="hr-line-dashed"></div>
        <div class="form-group posf">
          <div class="col-sm-4 col-sm-offset-2 text-right">
            <button class="btn btn-primary" type="submit">确定</button>
            <button class="btn btn-white" type="button" onclick="javascript:opt.closeWin();" value="取消">取消</button></div>
        </div>
      </form>
    </div>
  </div>
</div>
</body>
</html>